//
//  ZhiWeiGuanLiVC.m
//  EnterpriseEdition
//
//  Created by ypj on 2021/10/10.
//

#import "ZhiWeiGuanLiVC.h"
#import "ZhiWeiGuanLiListVC.h"
#import "XinZengZhiWeiVC.h"

@interface ZhiWeiGuanLiVC ()

@property (nonatomic, strong) NSMutableArray    *titleViewArray;
@property (nonatomic, strong) YJPageControlView *PageControlView;
@property (nonatomic, strong) NSMutableArray    *viewControllers;
@property (nonatomic, assign) NSInteger          selectIndex;
@property (nonatomic, strong) UIButton          *addButton;
@end

@implementation ZhiWeiGuanLiVC
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
   
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self layoutCustomNav:self.view title:@"职位管理"];
    
    [self createAddButton];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.titleViewArray = [NSMutableArray arrayWithArray:@[@"全部",@"已发布",@"已完成"]];
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    self.viewControllers = [NSMutableArray array];
    CGRect frame =CGRectMake(0, kViewTopHeight, ScreenWidth, B_HEIGHT - LL_StatusBarAndNavigationBarHeight - LL_TabbarSafeBottomMargin);
    
    for (int i = 0 ; i < self.titleViewArray.count; i++) {
        ZhiWeiGuanLiListVC *vc = [self viewControllerIndex:i];
        [self.viewControllers addObject:vc];
    }
     self.PageControlView = [[YJPageControlView alloc] initWithFrame:frame Titles:self.titleViewArray viewControllers:self.viewControllers Selectindex:0];
    [self.PageControlView showInViewController:self];
    
}
- (ZhiWeiGuanLiListVC *)viewControllerIndex:(NSInteger)index {
    ZhiWeiGuanLiListVC *vc = [[ZhiWeiGuanLiListVC alloc] init];
    
    switch (index){
        case 0:
        {
            vc.selectIndex = 0;
        }
            break;
        case 1:
        {
            vc.selectIndex = 1;
        }
            break;
        case 2:
        {
            vc.selectIndex = 2;
        }
            break;
        default:
            break;
    }
    return vc;
}


-(void)createAddButton{
    if (self.addButton){
        [self.addButton removeFromSuperview];
    }
    self.addButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.addButton.frame = CGRectMake(ScreenWidth - 20 - 60, KStatuesBarHeight, 60, 30);
    [_addButton setTitle:@"新增" forState:(UIControlStateNormal)];
    _addButton.backgroundColor = ColorWith3C6CFC;
    _addButton.titleLabel.font = [UIFont systemFontOfSize:13];
    _addButton.layer.masksToBounds = YES;
    _addButton.layer.cornerRadius = 2;
//    UIWindow *currentWindow = [BaseViewController getCurrentWindow];
    [self.view addSubview:self.addButton];
    BD_WEAKSELF
    [self.addButton whenTapped:^{
        XinZengZhiWeiVC *addVC = [[XinZengZhiWeiVC alloc] init];
        [weakSelf pushToNextController:addVC];
    }];
}

@end
